package com.lagou.test03;

public class PlayCard implements Comparable<PlayCard> {

    private String color;
    private String text;

    public void setColor(String color) {
        this.color = color;
    }


    public String getColor() {
        return color;
    }


    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public PlayCard() {
    }

    public PlayCard(String color, String text) {
        this.color = color;
        this.text = text;
    }

    @Override
    public String toString() {
        return "{" + color + text + '}';
    }

    private int compareNum(String text){

        //大王,小王,2,A,K,Q,J,10,9,8,7,6,5,4,3
        int count = 0;
        switch (text){
            case "大王": count = 15;break;
            case "小王": count = 14;break;
            case "2": count = 13;break;
            case "A": count = 12;break;
            case "K": count = 11;break;
            case "Q": count = 10;break;
            case "J": count = 9;break;
            case "10": count = 8;break;
            case "9": count = 7;break;
            case "8": count = 6;break;
            case "7": count = 5;break;
            case "6": count = 4;break;
            case "5": count = 3;break;
            case "4": count = 2;break;
            case "3": count = 1;break;
            default: count = 0;break;
        }

        return count;
    }

    //大王,小王,2,A,K,Q,J,10,9,8,7,6,5,4,3
    @Override
    public int compareTo(PlayCard o) {
        int num1 =  compareNum(this.getText());
        int num2 =  compareNum(o.getText());
        return num2-num1;
    }
}
